<template>
  <section
    @click="clickCurrent('current')"
    @mousedown="clickCurrent('dragging')"
  >
    <div :class="['custorm--modelbox', 'goodsother-show', (custormCurrent == custormIndex)?'drag active':'drag']">
      <div
        v-if="custormItemData.params.isshow == '2'"
        class="noshow"
        v-bind:style="{'background-image':`url(${getPath('noshow.png')})`}"
      ></div>
      <div>
        <div class="es-goods-group  three block">
          <div style="display: flex; align-items: center;">

            <div
              :class="['es-goods-item',_cindex==1?'active':'']"
              v-if="custormItemData.style.display == '1'&&_cindex<=2"
              v-for="(_citem, _cindex) in (custormItemData.params.choostype == '2'||custormItemData.params.choostype == '3')? custormItemData.params.listitem:custormItemData.params.chooseItemList.length>0?custormItemData.params.chooseItemList:custormItemData.data"
              :key="_cindex"
            >
              <div
                v-if="_cindex!=1"
                :class="['image',custormItemData.style.icon=='2'?'showIcon':'']"
              >
                <i
                  v-if="custormItemData.style.icon=='2'"
                  class="icon-attr"
                  v-bind:style="{'background-image':`url(${getPath('common_label2.png')})`}"
                >{{custormItemData.style.icontext}}</i>
                <img
                  :src="`${custormItemData.params.choostype != '1'?getPath('default_picture.png'):_citem.edit?getPath(_citem.edit.thumb):_citem.images[0]}`"
                  alt=""
                >
              </div>
              <div
                v-if="_cindex==1"
                :class="['image',custormItemData.style.icon=='2'?'showIcon':'']"
              >
                <i
                  v-if="custormItemData.style.icon=='2'"
                  class="icon-attr"
                  v-bind:style="{'background-image':`url(${getPath('common_label2.png')})`}"
                >{{custormItemData.style.icontext}}</i>
                <img
                  :src="`${custormItemData.params.choostype != '1'?getPath('default_picture.png'):_citem.edit?getPath(_citem.edit.thumb):_citem.images[0]}`"
                  alt=""
                >
              </div>
              <div
                v-if="_cindex==1"
                class="detail"
              >
                <div
                  class="name line-hide"
                  v-if="custormItemData.style.name"
                >{{custormItemData.params.choostype !=
                  '1'?'这里是商品标题':_citem.edit?_citem.edit.name:_citem.title}}</div>

                <div style="display: flex;">
                  <div style="flex: 1 1 0%;">
                    <div
                      class="price"
                      v-if="custormItemData.style.price"
                    ><span class="text">￥{{custormItemData.params.choostype
                        != '1'?'20':_citem.edit?_citem.edit.price:_citem.subprice}}</span>

                    </div>
                    <div class="sold">
                    </div>
                  </div>
                  <span
                    v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '1'"
                    class="buy buybtn1"
                  >购买</span>
                  <span
                    v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '2'"
                    class="buy buybtn6"
                  >+</span>
                  <span
                    v-if="custormItemData.style.buybtn == '1'&&custormItemData.style.buybtnstyle == '3'"
                    class="buy buybtn3"
                  ><i class="icon icon-cart"></i></span>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>

      <div
        style="overflow: hidden;"
        v-if="custormItemData.style.display == '2'"
      >
        <div
          class="es-goods-group  three2 block"
          style="white-space: nowrap;font-size:0;"
        >
          <div style="display:inline-block;">
            <div
              class="es-goods-item"
              v-for="(_citem, _cindex) in (custormItemData.params.choostype == '2'||custormItemData.params.choostype == '3')? custormItemData.params.listitem:custormItemData.params.chooseItemList.length>0?custormItemData.params.chooseItemList:custormItemData.data"
              :key="_cindex"
            >
              <div :class="['image',custormItemData.style.icon=='2'?'showIcon':'']">
                <i
                  v-if="custormItemData.style.icon=='2'"
                  class="icon-attr"
                  v-bind:style="{'background-image':`url(${getPath('common_label2.png')})`}"
                >{{custormItemData.style.icontext}}</i>
                <img
                  :src="`${custormItemData.params.choostype != '1'?getPath('default_picture.png'):_citem.edit?getPath(_citem.edit.thumb):_citem.images[0]}`"
                  alt=""
                >
              </div>
              <div class="detail">
                <div
                  class="name line-hide"
                  v-if="custormItemData.style.name"
                >
                  {{custormItemData.params.choostype != '1'?'这里是商品标题':_citem.edit?_citem.edit.name:_citem.title}}</div>

                <div style="display: flex;">
                  <div style="flex: 1 1 0%;">
                    <div
                      class="price"
                      v-if="custormItemData.style.price"
                    ><span class="text">￥{{custormItemData.params.choostype
                        != '1'?'20':_citem.edit?_citem.edit.price:_citem.subprice}}</span>

                    </div>
                    <div class="sold">

                    </div>
                  </div>

                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div
        class="btn-edit-del"
        @click="delCurrent"
      ><span class="btn-del iconfont icon icon-close"></span></div>
    </div>
  </section>
</template>

<script>
import defaultConfig from './utils/showConfig'
export default {
  mixins: [defaultConfig.mixins],
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.goodsother-show {
  .drag .btn-edit-del {
    height: 16px;
    width: 16px;
    position: absolute;
    right: 0;
    top: 0;
    display: none;
    z-index: 11;
    cursor: pointer;
    font-size: 14px;
    color: #fff;
    background: #fb6638;
    border-radius: 0 0 0 100%;
  }

  .drag .btn-edit-del .icon-close {
    font-size: 12px;
    position: absolute;
    right: 0;
    top: 0;
    left: 0;
    bottom: 0;
    text-align: right;
    line-height: 1.4;
  }

  .es-goods-group.three {
    display: -webkit-box !important;
    display: -webkit-flex !important;
    display: -ms-flexbox !important;
    display: flex !important;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
  }

  .block {
    display: block !important;
  }

  .es-goods-group {
    height: auto;
    background: #ffffffff;
  }

  .es-goods-group.block .es-goods-item {
    width: 50%;
    float: left;
    border-bottom: 0;
    background: none;
    padding: 5px;
    display: block;
    border-radius: 2px;
  }

  .es-goods-group.three .es-goods-item {
    width: 110px;
  }

  .es-goods-group.block .es-goods-item {
    border-radius: 4px;
  }

  .es-goods-item {
    position: relative;
    height: auto;
    padding: 14px;
    background: #fff;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
  }

  .es-goods-group.block .es-goods-item .image {
    float: none;
  }

  .es-goods-group.block .es-goods-item .image {
    width: 100%;
    height: auto;
    margin: 0;
    background-position: 50%;
    background-repeat: no-repeat;
    background-size: cover;
  }

  .es-goods-item .image {
    height: 100px;
    width: 100px;
    float: left;
    background-size: cover;
    position: relative;
    background-repeat: no-repeat;
    background-position: 50%;
  }

  .es-goods-item .image.showIcon .icon-attr {
    content: attr(data-text);
    position: absolute;
    top: -18px;
    left: -16px;
    width: 60px;
    height: 60px;
    background-size: 60px;
    z-index: 10;
    color: #fff;
    font-size: 21px;
    -webkit-transform: scale(0.5);
    transform: scale(0.5);
    padding-right: 7px;
    line-height: 12px;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    background-position: center;
    background-repeat: no-repeat;
  }

  .es-goods-group.block.three .es-goods-item .image img {
    height: 100px;
  }

  .es-goods-group.block .es-goods-item .image img {
    width: 100%;
    display: block;
    max-width: 100%;
    max-height: 100%;
  }

  .es-goods-item .image img {
    height: 100%;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
  }

  .es-goods-group.block.three .es-goods-item .detail {
    padding: 10px 6px;
  }

  .es-goods-group.block .es-goods-item .detail {
    padding: 8px;
    overflow: hidden;
    line-height: 1.5;
  }

  .es-goods-item .detail {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    line-height: 1.5;
    background: #fff;
    padding-left: 10px;
    display: flex;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    -webkit-box-orient: vertical;
    -ms-flex-direction: column;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between;
  }

  .three.es-goods-group.block .es-goods-item .detail .name {
    white-space: nowrap;
    display: block;
    height: 18px;
  }

  .es-goods-group .es-goods-item .detail .name {
    font-size: 13px;
    color: #3d404d;
    line-height: 1;
  }

  .es-goods-group .es-goods-item .detail .name {
    margin-top: 6px;
    font-size: 14px;
  }

  .line-hide,
  .two-line-hide {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .line-hide {
    white-space: nowrap;
  }

  .es-goods-item .detail .price {
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    font-size: 14px;
  }

  .es-goods-item .detail .price .text {
    color: #fd463e;
    font-weight: 700;
  }

  .es-goods-item .detail .price .text {
    color: #f55;
    font-size: 13px;
  }

  .es-goods-group.three .es-goods-item .price .text span {
    font-size: 12px;
  }

  .es-goods-item .detail .price .text span {
    font-size: 16px;
  }

  .es-goods-item .detail .buy.buybtn1 {
    border: 1px solid #f55;
    background: #f55;
  }

  .es-goods-item .detail .buy.buybtn3 {
    color: #f55;
    vertical-align: middle;
    width: 22px;
    padding: 0;
    text-align: center;
    line-height: 22px;
  }

  .es-goods-item .detail .buy.buybtn6 {
    vertical-align: middle;
    width: 20px;
    text-align: center;
    line-height: 20px;
    border-radius: 50%;
    color: #fff;
    background: #f55;
  }

  .es-goods-item .detail .buy {
    display: inline-block;
    height: 20px;
    color: #fff;
    line-height: 20px;
    padding: 0;
    width: 32px;
    border-radius: 2px;
    text-align: center;
    border: 1px solid transparent;
    float: right;
    font-size: 12px;
    -webkit-align-self: flex-end;
    -ms-flex-item-align: end;
    align-self: flex-end;
  }

  .es-goods-group:after {
    display: block;
    overflow: hidden;
    visibility: hidden;
    width: 0;
    height: 0;
    content: "";
    clear: both;
  }

  // dierge

  .es-goods-group.block.three2 .es-goods-item {
    width: 100px;
    box-sizing: border-box;
  }

  .es-goods-group.block .es-goods-item .image {
    float: none;
  }

  .es-goods-group.block .es-goods-item .image {
    width: 100%;
    height: auto;
    margin: 0;
    background-position: 50%;
    background-repeat: no-repeat;
    background-size: cover;
  }

  .es-goods-group.block .es-goods-item .image img {
    width: 100%;
    display: block;
    max-width: 100%;
    max-height: 100%;
  }

  .es-goods-group.block.three2 .es-goods-item {
    width: 100px;
  }

  .es-goods-group.block.three2 .es-goods-item img {
    height: 90px;
  }

  .es-goods-group .es-goods-item .detail .name {
    font-size: 13px;
    color: #3d404d;
    line-height: 1;
  }

  .es-goods-group.three .es-goods-item.active {
    width: 135px;
  }

  .es-goods-group.block.three2 {
    width: 9999px;
  }
}
</style>
